import { config ,baseApiUrl} from '../../config/cfg';
import {memberList} from '../../model/member/member';
import { getRequest, postRequest} from '../../utils/request';
const { delay } = require('../../utils/delay');
const app = getApp();

export const getMember=(phoneCard)=> {
  if (config.useMock) {
    return mockGetMember(phoneCard);
  }else{
    return realGetMember(phoneCard);
  }
 }

 function mockGetMember(phoneCard){
  return delay().then(()=>{
    let ts = memberList.filter(item=>(item.mobile===phoneCard || item.cardNo===phoneCard));
    if(ts && ts.length>0){
      return ts[0];
    }else{
      return null;
    }
  });
 }

 function realGetMember(phoneCard){
  var params = {url:baseApiUrl+'/真实子级地址?phoneCard='+phoneCard};
  return getRequest(params);
}